<%--
  Created by IntelliJ IDEA.
  User: liuxi
  Date: 2018/5/29
  Time: 20:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>添加公告</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/bootstrap/css/bootstrap.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/table/bootstrap-table.min.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/date/bootstrap-datetimepicker.min.css"/>
    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/statics/sweetalert.css"/>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/statics/sweetalert.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/jquery-3.2.1.min.js"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/statics/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/statics/table/bootstrap-table.min.js"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/statics/table/locale/bootstrap-table-zh-CN.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/date/Moment.js"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/statics/date/bootstrap-datetimepicker.min.js"></script>
    <style type="text/css">

    </style>
</head>
<body>

<%--添加模态框--%>
<div id="myModal" class="modal fade" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <form>
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">添加公告</h4>
                </div>
                <div class="modal-body">
                    <p>公告标题：<input type="text" name="notTitle"></p>
                </div>
                <div class="modal-body">
                    <p>公告内容：<input type="text" name="notText"></p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary add" >添加</button>
                </div>
            </form>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</body>
<script type="text/javascript">

    $(".add").bind("click",function(){
       var notTitle = $("input[name=notTitle]").val() ;
       var notText = $("input[name=notText]").val();

        if(notTitle==null||notTitle==''&&notText==null||notText==''){
            alert("请填写好完整信息！");
            return
        }
        if(notTitle==null||notTitle==''){
            alert("标题不能为空");
            return;
        }
        if(notText==null||notText==''){
            alert("内容不能为空");
            return;
        }
       $.ajax({
           "url":'${pageContext.request.contextPath}/Notice/add',
           "type":"post",
           "data":{"notTitle":notTitle,"notText":notText},
           "success":function(data){
               location = '${pageContext.request.contextPath}/Notice/Notice.jsp';
           },
           "error":function(){
               alert("添加失败");
           }
       })
    });

    $(function(){
         $("#myModal").modal("show");
    });
</script>
</html>
